<template>
  <div>
    <div class="login_box">
      <div class="login_head">
        <span
          class="iconfont icon-cancel-1-copy"
          @click="$router.push('/shopping')"
        ></span>
      </div>
      <div class="login">
        <h3>登录后继续操作</h3>
        <div class="box">
          <p>手机号码</p>
          <input type="text" placeholder="输入手机号码" v-model="pohone" />
        </div>
        <div class="box">
          <p>验证码</p>
          <input type="text" placeholder="输入验证码" v-model="ten" />
        </div>
        <div class="btn_box">
          <div :class="['btn', { btn_login: pohone }]">
            <p @click="goin">登录</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data: function () {
    return {
      pohone: "", //手机号码
      ten: "", //验证码
    };
  },
  methods: {
    //登录
    goin() {
      if (this.pohone == "15777536911" && this.ten == "1234") {
        //创建token值
        sessionStorage.setItem("token", this.pohone + this.ten);
        //存储用户名
        let user = {
          name: "一心向党",
          user_name: "日子真好",
          user_img:
            "https://img2.baidu.com/it/u=3886895525,3764775842&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
        };
        Toast("登录成功");
        sessionStorage.setItem("user", JSON.stringify(user));
        this.$router.push('/shopping');
      } else {
        Toast("账号验证码有误请重新输入");
        this.pohone = this.ten = ''
      }
    },
  },
};
</script>

<style lang="less">
.login_box {
  height: 100vh;
  background-color: #fff;
  .login_head {
    background-color: #fff;
    padding: 10px 25px;
    font-weight: bold;
  }
  .login {
    padding: 60px 40px 0;
    h3 {
      text-align: center;
      padding-bottom: 55px;
    }
    .box {
      display: flex;
      align-content: center;
      padding-bottom: 10px;
      border-bottom: 2px solid #fafafa;
      margin-bottom: 30px;
      p {
        width: 80px;
      }
      input {
        border: 0;
        :-moz-placeholder {
          color: #efecf1;
        }
      }
    }
    .btn_box {
      padding: 30px 0;
      .btn {
        background-color: #abaaba;
        height: 40px;
        line-height: 40px;
        text-align: center;
        color: #fff;
      }
      .btn_login {
        background-color: #00c2c2;
      }
    }
  }
}
</style>